<!DOCTYPE html>
<html>

<head>
    <title>Preview Display</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link type="text/css" rel="stylesheet" href="menu/meun.css">
    <style>
        html,
        body {
            padding: 0px;
            margin: 0px;
        }

        body {
            background: #000 url(./assets/兴达八厂/背景兴达.jpg) no-repeat left top;
            background-size: 100%;
        }
    </style>
    <script src="../libs/jquery-3.4.1.min.js"></script>
    <script src='../custom/libs/echarts.js'></script>
    <script src='../libs/core/ht.js'></script>
    <script src='../libs/plugin/ht-form.js'></script>
    <script src='../libs/plugin/ht-vector.js'></script>
    <script src="../conf/confURL.js"></script>
    <script src='../conf/dateTime.js'></script>
    <script>
        //获取图纸
        var url = domain + "/HT_DATA_EIGHT.getGlobalStatistics.do";
        dataModel = new ht.DataModel();
        graphView = new ht.graph.GraphView(dataModel);
        let warn = [];
        let H = [];
        let LED_circle = [];
        let button = [];
        let gasGraph;
        let gasGraph1;
        let waterGraph;
        let waterGraph1;
        let electricGraph;
        let electricGraph1;
        let RK;
        let RK1;
        let FH;
        let FH1;
        let gasGraphJS;
        let gasGraphSD;
        let gasGraphTG;
        let waterGraphJS;
        let waterGraphSD;
        let waterGraphTG;
        let electricGraphJS;
        let electricGraphSD;
        let electricGraphTG;
        var all_1;
        var all_2;
        function init() {
            graphView.addToDOM();
            ht.Default.xhrLoad('displays/智慧兴达/兴达八厂/生产监控/product_earth.json', function (text) {
                var json = ht.Default.parse(text);
                if (json.title) document.title = json.title;
                dataModel.deserialize(json);
                graphView.fitContent(true);
                tag();
                getData1('HT_SC_ZZ_TREE_XDJSXD');
                getData2('HT_SC_ZZ_TREE_XDJSXD');
                getData3('HT_SC_ZZ_TREE_XDJSXD');
                getData4();
                getData5();
                getData7();
                var a = getData6().HT_SC_ZZ_TREE
                cd = menu(a)
            });
            //时间日期               
            setInterval(function () {
                let dateTime = dataModel.getDataByTag('dateTime');
                let time = updateTime();
                dateTime.a('time', time);
            }, 1000);
            //更新数据
            setInterval(function a() { getData1(), getData2(), getData3() }, 1000 * 60 * 30);
            setInterval(function b() { getData4(), getData5() }, 1000 * 60 * 5);
            //用电量统计数据自动切换
            var time1 =
                setInterval(function () {
                    if (button[0].a("visible") == true) {
                        cut3(electricGraphSD)
                        button[0].a("visible", false);
                        button[1].a("visible", true);
                        button[2].a("visible", false);
                    } else if (button[1].a("visible") == true) {
                        cut3(electricGraphTG)
                        button[0].a("visible", false);
                        button[1].a("visible", false);
                        button[2].a("visible", true);
                    } else if (button[2].a("visible") == true) {
                        cut3(electricGraphJS)
                        button[0].a("visible", true);
                        button[1].a("visible", false);
                        button[2].a("visible", false);
                    }
                }, 1000 * 5);
            //水能耗数据自动切换
            var time2 =
                setInterval(function () { //饼图定时切换
                    if (button[3].a("visible") == true) {
                        cut2(waterGraphSD)
                        button[3].a("visible", false);
                        button[4].a("visible", true);
                        button[5].a("visible", false);
                    } else if (button[4].a("visible") == true) {
                        cut2(waterGraphTG)
                        button[3].a("visible", false);
                        button[4].a("visible", false);
                        button[5].a("visible", true);
                    } else if (button[5].a("visible") == true) {
                        cut2(waterGraphJS)
                        button[3].a("visible", true);
                        button[4].a("visible", false);
                        button[5].a("visible", false);
                    }
                }, 1000 * 5);
            //天然气数据自动切换
            var time3 =
                setInterval(function () { //饼图定时切换
                    if (button[6].a("visible") == true) {
                        cut1(gasGraphSD)
                        button[6].a("visible", false);
                        button[7].a("visible", true);
                        button[8].a("visible", false);
                    } else if (button[7].a("visible") == true) {
                        cut1(gasGraphTG)
                        button[6].a("visible", false);
                        button[7].a("visible", false);
                        button[8].a("visible", true);
                    } else if (button[8].a("visible") == true) {
                        cut1(gasGraphJS)
                        button[6].a("visible", true);
                        button[7].a("visible", false);
                        button[8].a("visible", false);
                    }
                }, 1000 * 5);
            //监听事件点击实现报表切换
            graphView.addInteractorListener(function (e) {
                if (e.kind === 'clickData') {
                    if (e.data._tag == 'button1') {
                        cut3(electricGraphJS)
                        button[0].a("visible", true)
                        for (let i = 1; i < 3; i++) {
                            button[i].a("visible", false)
                        }
                        clearInterval(time1)
                    }
                    else if (e.data._tag == 'button2') {
                        cut3(electricGraphSD)
                        button[1].a("visible", true);
                        button[0].a("visible", false);
                        button[2].a("visible", false);
                        clearInterval(time1)
                    }
                    else if (e.data._tag == 'button3') {
                        cut3(electricGraphTG)
                        button[2].a("visible", true)
                        for (let i = 0; i < 3 && i != 2; i++) {
                            button[i].a("visible", false)
                        }
                        clearInterval(time1)
                    }
                    else if (e.data._tag == 'button4') {
                        cut2(waterGraphJS)
                        button[3].a("visible", true);
                        button[4].a("visible", false);
                        button[5].a("visible", false);
                        clearInterval(time2)
                    }
                    else if (e.data._tag == 'button5') {
                        cut2(waterGraphSD)
                        button[4].a("visible", true);
                        button[3].a("visible", false);
                        button[5].a("visible", false);
                        clearInterval(time2)
                    }
                    else if (e.data._tag == 'button6') {
                        cut2(waterGraphTG)
                        button[5].a("visible", true);
                        button[3].a("visible", false);
                        button[4].a("visible", false);
                        clearInterval(time2)
                    }
                    else if (e.data._tag == 'button7') {
                        cut1(gasGraphJS)
                        button[6].a("visible", true);
                        button[7].a("visible", false);
                        button[8].a("visible", false);
                        clearInterval(time3)
                    }
                    else if (e.data._tag == 'button8') {
                        cut1(gasGraphSD)
                        button[7].a("visible", true);
                        button[6].a("visible", false);
                        button[8].a("visible", false);
                        clearInterval(time3)
                    }
                    else if (e.data._tag == 'button9') {
                        cut1(gasGraphTG)
                        button[8].a("visible", true);
                        button[6].a("visible", false);
                        button[7].a("visible", false);
                        clearInterval(time3)
                    }
                }
            });
        }
        // 获取标签
        function tag() {
            all_1 = dataModel.getDataByTag('all_1');
            all_2 = dataModel.getDataByTag('all_2');
            for (let i = 1; i < 11; i++) {
                warn.push(dataModel.getDataByTag("warn" + i));
            }
            for (let i = 1; i < 11; i++) {
                H.push(dataModel.getDataByTag("H" + i));
            }
            for (let i = 1; i < 33; i++) {
                LED_circle.push(dataModel.getDataByTag("LED_circle" + i));
            }
            for (let i = 1; i < 10; i++) {
                button.push(dataModel.getDataByTag("button" + i));
            };
            gasGraph = dataModel.getDataByTag('gasGraph');
            gasGraph1 = dataModel.getDataByTag('gasGraph1');
            waterGraph = dataModel.getDataByTag('waterGraph');
            waterGraph1 = dataModel.getDataByTag('waterGraph1');
            electricGraph = dataModel.getDataByTag('electricGraph');
            electricGraph1 = dataModel.getDataByTag('electricGraph1');
            RK = dataModel.getDataByTag('RK');
            RK1 = dataModel.getDataByTag('RK1');
            FH = dataModel.getDataByTag("FH");
            FH1 = dataModel.getDataByTag("FH1");
            gasGraphJS = getData1("HT_SC_ZZ_TREE_XDJSXD")
            gasGraphSD = getData1("HT_SC_ZZ_TREE_XD1106")
            gasGraphTG = getData1("HT_SC_ZZ_TREE_XD1121")
            waterGraphJS = getData2("HT_SC_ZZ_TREE_XDJSXD")
            waterGraphSD = getData2("HT_SC_ZZ_TREE_XD1106")
            waterGraphTG = getData2("HT_SC_ZZ_TREE_XD1121")
            electricGraphJS = getData3("HT_SC_ZZ_TREE_XDJSXD")
            electricGraphSD = getData3("HT_SC_ZZ_TREE_XD1106")
            electricGraphTG = getData3("HT_SC_ZZ_TREE_XD1121")
        }
        //天然气，水能耗，用电量数据获取
        function cut1(repData) {
            if (repData.HT_SC_DQ_REPORT_TRQTJ.data != null && repData.HT_SC_DQ_REPORT_TRQTJ.data != undefined && repData.HT_SC_DQ_REPORT_TRQTJ.data != '') {
                gasGraph.a("xAxis", repData.HT_SC_DQ_REPORT_TRQTJ.data.month);
                gasGraph.a("yAxis1", repData.HT_SC_DQ_REPORT_TRQTJ.data.gas);
                gasGraph1.a("xAxis", repData.HT_SC_DQ_REPORT_TRQTJ.data.month);
                gasGraph1.a("yAxis1", repData.HT_SC_DQ_REPORT_TRQTJ.data.gas);
            }
        }
        function cut2(repData) {
            if(repData.HT_SC_DQ_REPORT_SNHTJ.data != null && repData.HT_SC_DQ_REPORT_SNHTJ.data != undefined && repData.HT_SC_DQ_REPORT_SNHTJ.data != ''){
            waterGraph.a("xAxis", repData.HT_SC_DQ_REPORT_SNHTJ.data.month);
            waterGraph.a("yAxis1", repData.HT_SC_DQ_REPORT_SNHTJ.data.steam);
            // waterGraph.a("yAxis2", repData.HT_SC_DQ_REPORT_SNHTJ.data.circle);
            waterGraph.a("yAxis2", repData.HT_SC_DQ_REPORT_SNHTJ.data.industry);
            waterGraph1.a("xAxis", repData.HT_SC_DQ_REPORT_SNHTJ.data.month);
            waterGraph1.a("yAxis1", repData.HT_SC_DQ_REPORT_SNHTJ.data.steam);
            // waterGraph1.a("yAxis2", repData.HT_SC_DQ_REPORT_SNHTJ.data.circle);
            waterGraph1.a("yAxis2", repData.HT_SC_DQ_REPORT_SNHTJ.data.industry);
            }
        }
        function cut3(repData) {
            if(repData.HT_SC_DQ_REPORT_YDLTJ.data != null && repData.HT_SC_DQ_REPORT_YDLTJ.data != undefined && repData.HT_SC_DQ_REPORT_YDLTJ.data != ''){
            electricGraph.a("xAxis", repData.HT_SC_DQ_REPORT_YDLTJ.data.month);
            electricGraph.a("yAxis1", repData.HT_SC_DQ_REPORT_YDLTJ.data.electric);
            electricGraph1.a("xAxis", repData.HT_SC_DQ_REPORT_YDLTJ.data.month);
            electricGraph1.a("yAxis1", repData.HT_SC_DQ_REPORT_YDLTJ.data.electric);
            }
        }
        //天然气接口
        function err1() {
            warn[1].s("2d.visible", true);
            warn[6].s("2d.visible", true);
            gasGraph.s("2d.visible", false);
            gasGraph1.s("2d.visible", false);
        }
        function getData1(code) {
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_SC_DQ_REPORT_TRQTJ",
                    factoryCode: code
                },
                headers: request_headers,
                async: false,
                // contentType: 'application/x-www-form-urlencoded',
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.visible == "true") {
                        warn[1].s("2d.visible", false);
                        warn[6].s("2d.visible", false);
                        gasGraph.s("2d.visible", true);
                        gasGraph1.s("2d.visible", true);
                        H[0].s("text", repData.HT_SC_DQ_REPORT_TRQTJ.title);
                        H[5].s("text", repData.HT_SC_DQ_REPORT_TRQTJ.title);
                        cut1(repData)
                    } else {
                        err1()
                    }
                },
                error: function (error) {
                    //console.log('err'); 
                    err1()
                }
            })
            return repData
        }
        //水能耗接口
        function err2() {
            warn[2].s("2d.visible", true);
            warn[7].s("2d.visible", true);
            waterGraph.s("2d.visible", false);
            waterGraph1.s("2d.visible", false);
        }
        function getData2(code) {
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_SC_DQ_REPORT_SNHTJ",
                    factoryCode: code
                },
                headers: request_headers,
                async: false,
                contentType: 'application/x-www-form-urlencoded',
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.visible == "true") {
                        warn[2].s("2d.visible", false);
                        warn[7].s("2d.visible", false);
                        waterGraph.s("2d.visible", true);
                        waterGraph1.s("2d.visible", true);
                        H[1].s("text", repData.HT_SC_DQ_REPORT_SNHTJ.title);
                        H[6].s("text", repData.HT_SC_DQ_REPORT_SNHTJ.title);
                        cut2(repData)
                    } else {
                        err2()
                    }
                },
                error: function (error) {
                    // console.log('err');
                    err2()
                }
            })
            return repData
        }
        //用电量接口 
        function err3() {
            warn[3].s("2d.visible", true);
            warn[8].s("2d.visible", true);
            electricGraph.s("2d.visible", false);
            electricGraph1.s("2d.visible", false);
        }
        function getData3(code) {
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_SC_DQ_REPORT_YDLTJ",
                    factoryCode: code
                },
                headers: request_headers,
                async: false,
                contentType: 'application/x-www-form-urlencoded',
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.visible == "true") {
                        warn[3].s("2d.visible", false);
                        warn[8].s("2d.visible", false);
                        electricGraph.s("2d.visible", true);
                        electricGraph1.s("2d.visible", true);
                        H[2].s("text", repData.HT_SC_DQ_REPORT_YDLTJ.title);
                        H[7].s("text", repData.HT_SC_DQ_REPORT_YDLTJ.title);
                        cut3(repData)
                    } else {
                        err3()
                    }
                },
                error: function (error) {
                    //console.log('err');
                    err3()
                }
            })
            return repData
        }
        //入库统计接口
        function err4() {
            warn[0].s("2d.visible", true);
            warn[5].s("2d.visible", true);
            RK.s("2d.visible", false);
            RK1.s("2d.visible", false);
        }
        function getData4() {
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: { props: "HT_SC_DQ_REPORT_RKTJ" },
                headers: request_headers,
                async: true,
                //contentType: 'application/x-www-form-urlencoded',
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.visible == "true") {
                        warn[0].s("2d.visible", false);
                        warn[5].s("2d.visible", false);
                        RK.s("2d.visible", true);
                        RK1.s("2d.visible", true);
                        H[3].s("text", repData.HT_SC_DQ_REPORT_RKTJ.title);
                        H[8].s("text", repData.HT_SC_DQ_REPORT_RKTJ.title);
                        for (let i = 0; i < repData.HT_SC_DQ_REPORT_RKTJ.data.length; i++) {
                            LED_circle[i].a("rukuliang", repData.HT_SC_DQ_REPORT_RKTJ.data[i].scheduledReceipt);
                            LED_circle[i].a("jihuachanliang", repData.HT_SC_DQ_REPORT_RKTJ.data[i].plannedProduction);
                            LED_circle[i].a("process", repData.HT_SC_DQ_REPORT_RKTJ.data[i].completionRate);
                        };
                        for (let i = 0; i < repData.HT_SC_DQ_REPORT_RKTJ.data.length; i++) {
                            LED_circle[i + 24].a("rukuliang", repData.HT_SC_DQ_REPORT_RKTJ.data[i].scheduledReceipt);
                            LED_circle[i + 24].a("jihuachanliang", repData.HT_SC_DQ_REPORT_RKTJ.data[i].plannedProduction);
                            LED_circle[i + 24].a("process", repData.HT_SC_DQ_REPORT_RKTJ.data[i].completionRate);
                        };
                    } else {
                        err4()
                    }
                },
                error: function (error) {
                    //console.log('err');
                    err4()
                }
            })
            return repData
        }
        //发货统计接口
        function err5() {
            warn[4].s("2d.visible", true);
            warn[9].s("2d.visible", true);
            FH.s("2d.visible", false);
            FH1.s("2d.visible", false);;
        }
        function getData5() {
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: { props: "HT_SC_DQ_REPORT_FHTJ" },
                headers: request_headers,
                async: true,
                contentType: 'application/x-www-form-urlencoded',
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.visible == "true") {
                        warn[4].s("2d.visible", false);
                        warn[9].s("2d.visible", false);
                        FH.s("2d.visible", true);;
                        FH1.s("2d.visible", true);
                        H[4].s("text", repData.HT_SC_DQ_REPORT_FHTJ.title);
                        H[9].s("text", repData.HT_SC_DQ_REPORT_FHTJ.title);
                        for (let i = 0; i < repData.HT_SC_DQ_REPORT_FHTJ.data.length; i++) {
                            LED_circle[i + 8].a("rukuliang", repData.HT_SC_DQ_REPORT_FHTJ.data[i].deliverAmount);
                            LED_circle[i + 8].a("jihuachanliang", repData.HT_SC_DQ_REPORT_FHTJ.data[i].plannedProduction);
                            LED_circle[i + 8].a("process", repData.HT_SC_DQ_REPORT_FHTJ.data[i].completionRate);
                        };
                        for (let i = 0; i < repData.HT_SC_DQ_REPORT_FHTJ.data.length; i++) {
                            LED_circle[i + 16].a("rukuliang", repData.HT_SC_DQ_REPORT_FHTJ.data[i].deliverAmount);
                            LED_circle[i + 16].a("jihuachanliang", repData.HT_SC_DQ_REPORT_FHTJ.data[i].plannedProduction);
                            LED_circle[i + 16].a("process", repData.HT_SC_DQ_REPORT_FHTJ.data[i].completionRate);
                        }
                    } else {
                        err5()
                    }
                },
                error: function (error) {
                    // console.log('err');
                    err5()
                }
            })
            return repData
        }
        //菜单树接口
        function getData6() {
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: { props: "HT_SC_ZZ_TREE" },
                headers: request_headers,
                async: false,
                contentType: 'application/x-www-form-urlencoded',
                success: function (res) {
                    repData = JSON.parse(res, handleJson);
                    if (repData._MSG_ === 'OK' && repData.visible == true) {
                        document.getElementById("node").style.display = "block"
                    } else {
                        document.getElementById("node").style.display = "none"
                    }
                },
                error: function (error) {
                    console.log('err');
                    document.getElementById("node").style.display = "none"
                }
            })
            return repData
        }
        //地图跳转地址 
        function getData7() {
            let shandong = dataModel.getDataByTag('shandong');
            let jiangsu = dataModel.getDataByTag('jiangsu');
            let taiguo = dataModel.getDataByTag('taiguo');
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: { props: "HT_SC_ZZ_MAP_LINK" },
                headers: request_headers,
                async: true,
                contentType: 'application/x-www-form-urlencoded',
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.HT_SC_ZZ_MAP_LINK.visible == "true") {
                        jiangsu.s("label", repData.HT_SC_ZZ_MAP_LINK.data);
                        shandong.s("label", repData.HT_SC_ZZ_MAP_LINK.data);
                        taiguo.s("label", repData.HT_SC_ZZ_MAP_LINK.data);
                    }
                },
                error: function (error) {
                    // console.log('err');
                }
            })
        }  
    </script>
</head>

<body onload='setTimeout(init, 300)'>
    <div id="ct">
        <div id="abc" style="display:none;height: 100%; width:95%">
            <div id="app"
                style="background:url(menu/tree3.png) no-repeat; background-size:100% 100%;position: absolute;z-index:20; width: 11%; height:85%;top:10.5%;overflow: hidden;">
                <span id="total" style="font-size:18px";>兴达公司</span>
                <img class="lin" src="menu/line.png">
                </br></br></br></br>
            </div>
        </div>
        <div id="node"
            style="left:0px;display:block;background-color:rgba(red, green, blue, 0);position:absolute;width: 33px;height: 650px;top: 80px;z-index: 100;">
        </div>
    </div>
</body>

</html>